<!DOCTYPE html>
<html class="pixel-ratio-3 retina android android-5 android-5-1-1">
<head>
    <title>药材搜索</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="">

    <link rel="stylesheet" href="../../lib/weui.min.css">
    <link rel="stylesheet" href="../../css/jquery-weui.css">
    <link rel="stylesheet" href="../../css/home.css">
    <link rel="stylesheet" href="../../plugins/fontaw/css/font-awesome.css">
    <style>
        .kk-full-block {
            margin: 0rem
        }
    </style>
</head>
<body ontouchstart>
<div class="kk-container">
    <div class="weui-search-bar" id="searchBar">
        <form class="weui-search-bar__form">
            <div class="weui-search-bar__box">
                <i class="weui-icon-search"></i>
                <input type="search" class="weui-search-bar__input" id="searchInput" placeholder="搜索" required="">
                <a href="javascript:void(0);" class="weui-icon-clear" id="searchClear"></a>
            </div>
            <label class="weui-search-bar__label" id="searchText">
                <i class="weui-icon-search"></i>
                <span>搜索</span>
            </label>
            <input type="submit" value="test"/>
        </form>
        <a href="javascript:void(0);" class="weui-search-bar__cancel-btn" id="searchCancel">取消</a>
    </div>
    <div class="slide-wraper">
        <div class="slide-box">
        </div>
    </div>

    <div>
        <ul class="kk-ul-ho">

        </ul>
    </div>

</div>

<div class="weui-tabbar" style="padding:0.3rem;text-align: center">
    <a class="weui-btn weui-btn_primary" onclick="doCommit()" href="javacript:void(0);" >确认添加</a>
</div>

<script src="/lib/jquery-2.1.4.js"></script>
<script src="/js/jquery-weui.js"></script>

<script>
    $(".weui-search-bar__form").submit(function () {
        $.ajax({
            type: "POST",
            url: '/prescription/getAllMedicals',
            data: {"name": $("#searchInput").val()},
            success: function (data) {
                $(".slide-box").html(data);
            },
            error: function () {
            }
        })
        return false;
    });

    $(".kk-ul-ho").delegate("a", "click", function () {
        $(this).parent().remove();
    });
    var buildItem = function (id, medicalName) {
        var li = " <li>\n" +
                "                <a><i class=\"fa fa-minus-circle\" aria-hidden=\"true\" style=\"color: darkred\"></i></a>\n" +
                "                <span class='medicalId' id='" + id + "'>" + medicalName + "</span>\n" +
                "                <div style=\"display: -webkit-inline-box;float:right\">\n" +
                "                    <input class=\"tinyInput\" type=\"number\"/>g\n" +
                "                </div>\n" +
                "            </li>";
        $(".kk-ul-ho").append(li);
    }

    var doCommit = function () {
        var medicalList = [];
        $(".kk-ul-ho").children().each(function () {
            var object = {};
            object.id = $(this).children(".medicalId").attr("id");
            object.count = $(this).children("div").children().val();
            medicalList.push(object);
        });
    }
</script>
</body>
</html>